package com.action.boot.jpa.service;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * Created by Wuxiang on 2017/3/27.
 */
@Service
public class CacheService {

    private static int count=0;

    public static int getCount() {
        return count;
    }

    @Cacheable("data")
    public String getData(String key) {
        System.out.println("actually did service.");
        count++;
        return "back-" + key;
    }

    @CacheEvict("data")
    public void deleteData(String key){
        System.out.println("delete: "+key);
    }
}
